// Encrypt.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <Windows.h>
#include <atlbase.h>
#include <string>
#include <iostream>
using namespace std;

#include "logclient\Base64.h"
#include "logclient\SimpleEncrypt.h"
using namespace PPLiveLogClient;

string strEncryption(string& strInput, char* pKey, int keySize)
{
	CStringA input(strInput.c_str());
	
	SimpleEncrypt encrypt(pKey);
	SimpleBinaryData data = encrypt.Encrypt(input);
	Base64 base64;
	CStringA params( base64.Encode(data) );

	char* output=params.GetBuffer(params.GetLength()); 
	params.ReleaseBuffer();
	return output;
}

int _tmain(int argc, _TCHAR* argv[])
{
	string duid = "0x180373c4220000";
	char* pKey = "pplive_vas";
	int keySize = strlen(pKey);

	string strUrlAppend = strEncryption(duid, pKey, keySize);
	cout<<strUrlAppend<<endl;

	int n = 65535;
	char t[MAX_PATH];
	string s;

	sprintf_s(t, MAX_PATH,"%d", n);
	s = t;
	cout<<s<<endl;

	return 0;
}

